'=====================================================================  	
'
'  File:       PackageEvents.vb
'
'  Summary:    This file contains a Control flow sample.
'
'  Date:       06/09/2005
'
'---------------------------------------------------------------------
'  This file is part of the Microsoft SQL Server Code Samples.
'  Copyright (C) Microsoft Corporation.  All rights reserved.
'
'  This source code is intended only as a supplement to Microsoft
'  Development Tools and/or on-line documentation.  See these other
'  materials for detailed information regarding Microsoft code samples.
'
'  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF 
'  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
'  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'  PARTICULAR PURPOSE.
'=====================================================================                         

Public NotInheritable Class PackageEvents
    Implements IDTSEvents
#Region "IDTSEvents Members"

    Sub OnBreakpointHit(ByVal breakpointSite As IDTSBreakpointSite, ByVal breakpointTarget As BreakpointTarget) Implements IDTSEvents.OnBreakpointHit
    End Sub

    Sub OnCustomEvent(ByVal taskHost As TaskHost, ByVal eventName As String, ByVal eventText As String, ByRef arguments() As Object, ByVal subComponent As String, ByRef fireAgain As Boolean) Implements IDTSEvents.OnCustomEvent
    End Sub

    <System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")> Function OnError(ByVal source As DtsObject, ByVal errorCode As Integer, ByVal subComponent As String, ByVal description As String, ByVal helpFile As String, ByVal helpContext As Integer, ByVal idofInterfaceWithError As String) As Boolean Implements IDTSEvents.OnError
        Dim sourceExec As String = CType(source, IDTSName).Name
        Console.WriteLine("IDTSEvents.OnError " & vbLf _
            & "ErrorCode " & errorCode & vbLf _
            & "Source " & sourceExec & vbLf _
            & "SubComponent " & subComponent & vbLf _
            & "Description " & description & vbLf _
            & "IDOfInterfaceWithError " & idofInterfaceWithError & vbLf)
        Return False
    End Function

    Sub OnExecutionStatusChanged(ByVal exec As Executable, ByVal newStatus As DTSExecStatus, ByRef fireAgain As Boolean) Implements IDTSEvents.OnExecutionStatusChanged
    End Sub

    Sub OnInformation(ByVal [source] As DtsObject, ByVal informationCode As Integer, ByVal subComponent As String, ByVal description As String, ByVal helpFile As String, ByVal helpContext As Integer, ByVal idofInterfaceWithError As String, ByRef fireAgain As Boolean) Implements IDTSEvents.OnInformation
        Console.WriteLine("IDTSEvents.OnInformation" & vbLf & "SubComponent: " & subComponent & vbLf & "Description: " & description)
    End Sub

    Sub OnPostExecute(ByVal exec As Executable, ByRef fireAgain As Boolean) Implements IDTSEvents.OnPostExecute
        Dim th As TaskHost = TryCast(exec, TaskHost)
        Dim p As Package = TryCast(exec, Package)
        Dim dtsCon As DtsContainer = TryCast(exec, DtsContainer)

        Console.Write("IDTSEvents.OnPostExecute - ")

        If th Is Nothing And p Is Nothing Then
            Console.WriteLine("Container: " & dtsCon.Name & vbCrLf)
        ElseIf th Is Nothing Then
            Console.WriteLine("Package: " & p.Name & vbCrLf)
        ElseIf p Is Nothing Then
            Console.WriteLine("TaskHost: " & th.Name & vbCrLf)
        Else
            Console.WriteLine()
        End If
    End Sub

    Sub OnPostValidate(ByVal exec As Executable, ByRef fireAgain As Boolean) Implements IDTSEvents.OnPostValidate
        Dim th As TaskHost = TryCast(exec, TaskHost)
        Dim p As Package = TryCast(exec, Package)
        Dim dtsCon As DtsContainer = TryCast(exec, DtsContainer)

        Console.Write("IDTSEvents.OnPostValidate - ")

        If th Is Nothing And p Is Nothing Then
            Console.WriteLine("Container: " & dtsCon.Name & vbCrLf)
        ElseIf th Is Nothing Then
            Console.WriteLine("Package: " & p.Name & vbCrLf)
        ElseIf p Is Nothing Then
            Console.WriteLine("TaskHost: " & th.Name & vbCrLf)
        Else
            Console.WriteLine()
        End If
    End Sub

    Sub OnPreExecute(ByVal exec As Executable, ByRef fireAgain As Boolean) Implements IDTSEvents.OnPreExecute
        Dim th As TaskHost = TryCast(exec, TaskHost)
        Dim p As Package = TryCast(exec, Package)
        Dim dtsCon As DtsContainer = TryCast(exec, DtsContainer)

        Console.Write("IDTSEvents.OnPreExecute - ")

        If th Is Nothing And p Is Nothing Then
            Console.WriteLine("Container: " & dtsCon.Name & vbCrLf)
        ElseIf th Is Nothing Then
            Console.WriteLine("Package: " & p.Name & vbCrLf)
        ElseIf p Is Nothing Then
            Console.WriteLine("TaskHost: " & th.Name & vbCrLf)
        Else
            Console.WriteLine()
        End If
    End Sub

    Sub OnPreValidate(ByVal exec As Executable, ByRef fireAgain As Boolean) Implements IDTSEvents.OnPreValidate
        Dim th As TaskHost = TryCast(exec, TaskHost)
        Dim p As Package = TryCast(exec, Package)
        Dim dtsCon As DtsContainer = TryCast(exec, DtsContainer)

        Console.Write("IDTSEvents.OnPreValidate - ")

        If th Is Nothing And p Is Nothing Then
            Console.WriteLine("Container: " & dtsCon.Name & vbCrLf)
        ElseIf th Is Nothing Then
            Console.WriteLine("Package: " & p.Name & vbCrLf)
        ElseIf p Is Nothing Then
            Console.WriteLine("TaskHost: " & th.Name & vbCrLf)
        Else
            Console.WriteLine()
        End If
    End Sub

    <System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")> Sub OnProgress(ByVal taskHost As TaskHost, ByVal progressDescription As String, ByVal percentComplete As Integer, ByVal progressCountLow As Integer, ByVal progressCountHigh As Integer, ByVal subComponent As String, ByRef fireAgain As Boolean) Implements IDTSEvents.OnProgress
        Console.WriteLine("IDTSEvents.OnProgress " & vbLf & "TaskHost " & taskHost.Name & vbLf & "ProgressDescription " & progressDescription & vbLf & "PercentComplete " & percentComplete.ToString(CultureInfo.InvariantCulture) & vbLf)
    End Sub

    Function OnQueryCancel() As Boolean Implements IDTSEvents.OnQueryCancel
        Return False
    End Function

    <System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")> Sub OnTaskFailed(ByVal taskHost As TaskHost) Implements IDTSEvents.OnTaskFailed
        Console.WriteLine("IDTSEvents.OnTaskFailed " & taskHost.Name & vbLf)
    End Sub

    Sub OnVariableValueChanged(ByVal DtsContainer As DtsContainer, ByVal variable As Variable, ByRef fireAgain As Boolean) Implements IDTSEvents.OnVariableValueChanged
    End Sub

    <System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")> Sub OnWarning(ByVal source As DtsObject, ByVal warningCode As Integer, ByVal subComponent As String, ByVal description As String, ByVal helpFile As String, ByVal helpContext As Integer, ByVal idofInterfaceWithError As String) Implements IDTSEvents.OnWarning
        Dim sourceExec As String = CType([source], IDTSName).Name
        Console.WriteLine("IDTSEvents.OnWarning " & vbLf & "WarningCode " & warningCode & vbLf & "Source  " & sourceExec & vbLf & "SubComponent " & subComponent & vbLf & "Description " & description & "IDOfInterfaceWithError " & idofInterfaceWithError & vbLf)
    End Sub

#End Region
End Class